package com.itheima.homework.homework04;

class Person{
    private String name;
    private int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}

class Student extends Person {

    //任何情况下,必须保证: 有参无参都存在!
    public Student() {
    }

    public Student(String name, int age) {
        super(name, age);
    }
}

//请对下列继承代码进行优化和丰富，使得创建子类对象的时候，
// 可以通过有参构造进行初始化，随后通过getXxx方法获取属性并输出。
//运行结果
//张三...23
public class Test04 {
    public static void main(String[] args) {
        Student s = new Student();
        s.setName("张三");
        s.setAge(23);

        //通过有参构造进行初始化
        Student s1 = new Student("张三",23);
        //通过getXxx方法获取属性并输出
        System.out.println(s1.getName()+"..." + s1.getAge());
    }
}

